home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.image;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.image.ImageObserver;
- import java.awt.image.ImageProducer;
- import java.util.Enumeration;
- import java.util.Hashtable;
-
- public abstract class Image extends java.awt.Image {
- ImageProducer source;
- InputStreamImageSource src;
- ImageInfoGrabber info;
- private int width = -1;
- private int height = -1;
- private Hashtable properties;
- private int availinfo;
- Hashtable representations = new Hashtable();
- ImageRepresentation baseIR;
-
- protected Image() {
- }
-
- protected Image(int var1, int var2) {
- OffScreenImageSource var3 = new OffScreenImageSource((Component)null, var1, var2);
- this.source = var3;
- this.width = var1;
- this.height = var2;
- this.availinfo |= 3;
- ImageRepresentation var4 = this.getImageRep(-1, -1);
- this.representations.put(var1 + "x" + var2, var4);
- this.representations.put("-1x-1", var4);
- var4.setDimensions(var1, var2);
- var4.offscreenInit102();
- var3.setImageRep(var4);
- }
-
- protected Image(Component var1, int var2, int var3) {
- OffScreenImageSource var4 = new OffScreenImageSource(var1, var2, var3);
- this.source = var4;
- this.width = var2;
- this.height = var3;
- this.availinfo |= 3;
- ImageRepresentation var5 = this.getImageRep(-1, -1);
- this.representations.put(var2 + "x" + var3, var5);
- this.representations.put("-1x-1", var5);
- this.baseIR = var5;
- var5.setDimensions(var2, var3);
- var5.offscreenInit(var1.getBackground());
- var4.setImageRep(var5);
- }
-
- protected Image(ImageProducer var1) {
- this.source = var1;
- if (var1 instanceof InputStreamImageSource) {
- this.src = (InputStreamImageSource)var1;
- }
-
- this.info = new ImageInfoGrabber(this);
- this.info.setupConsumer();
- }
-
- public ImageProducer getSource() {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- return this.source;
- }
-
- protected void initGraphics(Graphics var1) {
- OffScreenImageSource var2 = (OffScreenImageSource)this.source;
- var1.setColor(var2.target.getForeground());
- var1.setFont(var2.target.getFont());
- }
-
- public Color getBackground() {
- OffScreenImageSource var1 = (OffScreenImageSource)this.source;
- return var1.target.getBackground();
- }
-
- public int getWidth() {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 1) == 0) {
- this.reconstruct(1);
- }
-
- return this.width;
- }
-
- public synchronized int getWidth(ImageObserver var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 1) == 0) {
- this.addWatcher(var1, true);
- return -1;
- } else {
- return this.width;
- }
- }
-
- public int getHeight() {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 2) == 0) {
- this.reconstruct(2);
- }
-
- return this.height;
- }
-
- public synchronized int getHeight(ImageObserver var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 2) == 0) {
- this.addWatcher(var1, true);
- return -1;
- } else {
- return this.height;
- }
- }
-
- public Object getProperty(String var1, ImageObserver var2) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if (this.properties == null) {
- this.addWatcher(var2, true);
- return null;
- } else {
- Object var3 = this.properties.get(var1);
- if (var3 == null) {
- var3 = java.awt.Image.UndefinedProperty;
- }
-
- return var3;
- }
- }
-
- public boolean hasError() {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- return (this.availinfo & 64) != 0;
- }
-
- public int check(ImageObserver var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 64) == 0 && (~this.availinfo & 7) != 0) {
- this.addWatcher(var1, false);
- }
-
- return this.availinfo;
- }
-
- public void preload(ImageObserver var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 32) == 0) {
- this.addWatcher(var1, true);
- }
-
- }
-
- private synchronized void addWatcher(ImageObserver var1, boolean var2) {
- if ((this.availinfo & 64) != 0) {
- if (var1 != null) {
- var1.imageUpdate(this, 192, -1, -1, -1, -1);
- }
-
- } else {
- if (this.info == null) {
- this.info = new ImageInfoGrabber(this);
- this.info.setupConsumer();
- }
-
- this.info.addWatcher(var1);
- if (var2) {
- this.info.getInfo();
- }
-
- }
- }
-
- private synchronized void reconstruct(int var1) {
- if ((var1 & ~this.availinfo) != 0) {
- if ((this.availinfo & 64) != 0) {
- return;
- }
-
- if (this.info == null) {
- this.info = new ImageInfoGrabber(this);
- }
-
- this.info.getInfo();
-
- while((var1 & ~this.availinfo) != 0) {
- try {
- this.wait();
- } catch (InterruptedException var2) {
- Thread.currentThread().interrupt();
- return;
- }
-
- if ((this.availinfo & 64) != 0) {
- return;
- }
- }
- }
-
- }
-
- synchronized void addInfo(int var1) {
- this.availinfo |= var1;
- this.notifyAll();
- if ((~this.availinfo & 7) == 0) {
- this.info.stopInfo();
- }
-
- }
-
- void setDimensions(int var1, int var2) {
- this.width = var1;
- this.height = var2;
- this.addInfo(3);
- }
-
- void setProperties(Hashtable var1) {
- if (var1 == null) {
- var1 = new Hashtable();
- }
-
- this.properties = var1;
- this.addInfo(4);
- }
-
- synchronized void infoDone(int var1) {
- if (var1 != 1 && (~this.availinfo & 3) == 0) {
- if ((this.availinfo & 4) == 0) {
- this.setProperties((Hashtable)null);
- }
-
- } else {
- this.addInfo(64);
- }
- }
-
- public void flush() {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if (!(this.source instanceof OffScreenImageSource)) {
- synchronized(this){}
-
- Enumeration var1;
- try {
- this.availinfo &= -65;
- var1 = this.representations.elements();
- this.representations = new Hashtable();
- this.baseIR = null;
- if (this.source instanceof InputStreamImageSource) {
- ((InputStreamImageSource)this.source).flush();
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- while(var1.hasMoreElements()) {
- ImageRepresentation var2 = (ImageRepresentation)var1.nextElement();
- var2.abort();
- }
- }
-
- }
-
- protected ImageRepresentation getImageRep(int var1, int var2) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- String var3;
- if ((var1 == -1 || var1 == this.width) && (var2 == -1 || var2 == this.height)) {
- if (this.baseIR != null) {
- return this.baseIR;
- }
-
- var3 = "-1x-1";
- } else {
- var3 = var1 + "x" + var2;
- }
-
- ImageRepresentation var4 = (ImageRepresentation)this.representations.get(var3);
- if (var4 == null) {
- synchronized(this){}
-
- try {
- var4 = (ImageRepresentation)this.representations.get(var3);
- if (var4 == null) {
- var4 = new ImageRepresentation(this, var1, var2, 0);
- if (this.source instanceof OffScreenImageSource) {
- var4.offscreen = true;
- } else {
- this.representations.put(var3, var4);
- }
-
- if (var1 == -1 && var2 == -1) {
- this.baseIR = var4;
- }
- }
- } catch (Throwable var7) {
- throw var7;
- }
- }
-
- return var4;
- }
- }
-